#include "entry/signal/SignalEntry.h"
#include <windows.h>
#include <cctype>
#include <QtConcurrent/QtConcurrent>
#include "solar/trunk/NReaptFruit.h"
#include <QGraphicsVideoItem>




SignalDoor::SignalDoor(QMainWindow *parent):DoorLogic(parent){
    GLOBAL_ARGUR_QTIER.setInterval(30);
    GLOBAL_ARGUR_QTIER.setSingleShot(true);

    connect(FC_anlTool, &NinsipidView::msev_pre, this, &SignalDoor::open_analy_tool);
    connect(FC_player, &NinsipidView::msev_pre, this, &SignalDoor::open_mdplr);
    connect(this, &SignalDoor::bsic_quit, this, [this](){mainloginc_quitrequest(false, NT::MAIN_DOOR_QUIT);});
    connect(config_open, &NinsipidView::msev_rls, this, &SignalDoor::confile_opening);
    connect(config_save, &NinsipidView::msev_rls, this, &SignalDoor::confile_save);
    connect(config_update, &NinsipidView::msev_rls, this, &SignalDoor::confile_amend);
    connect(config_reset, &NinsipidView::msev_rls, this, &SignalDoor::confile_reset);
    connect(this, &SignalDoor::configAmend, this, [&](){GLOBAL_ARGUR_QTIER.start();});
    connect(&GLOBAL_ARGUR_QTIER, &QTimer::timeout, this, &SignalDoor::mang_dependableload); GLOBAL_ARGUR_QTIER.start();

}



void SignalDoor::open_analy_tool(){
    AnalyTool = new SignalTool(RGLRLSMAP, DATABASE, QSSMAP);
    connect(AnalyTool, &SignalTool::bsic_nrrls, this, &SignalDoor::main_childrs_back);
    connect(AnalyTool, &SignalTool::sg_system_quit, this, &SignalDoor::mainloginc_quitrequest);
    // connect(this, &DoorWin::configAmend, this, [&](){AnalyTool->basic_configration_init();});
    AnalyTool->setAttribute(Qt::WA_DeleteOnClose);
    mainloginc_quitrequest(false, NT::WIN_QUIT_ATTRIBUTE::CHILD_TOOL_QUIT);
    setVisible(false);
    diary("analytool is opening", Diary::Success)
}

void SignalDoor::open_mdplr(){
    SimpleMedia = new SignalMedia(RGLRLSMAP, DATABASE, QSSMAP);
    connect(SimpleMedia, &SignalDoor::bsic_nrrls, this, &SignalDoor::main_childrs_back);
    connect(SimpleMedia, &SignalMedia::sg_system_quit, this, &SignalDoor::mainloginc_quitrequest);
    connect(this, &DoorWin::configAmend, this, [&](){SimpleMedia->basic_configration_init();});
    SimpleMedia->setAttribute(Qt::WA_DeleteOnClose);
    mainloginc_quitrequest(false, NT::WIN_QUIT_ATTRIBUTE::CHILD_MEDIA_QUIT);
    setVisible(false);
    diary("mediaplayer is opening", Diary::Success)
}

void SignalDoor::main_childrs_back(){
    if (isVisible())
    {
        activateWindow();
    }
    else
    {
        setVisible(true);
    }
}
